<?php
function encode($word){$word.=' ';$str=str_split($word);$i=0;$xau='';$n=0;while ($i<=strlen($word))	{if ($str[$i]!='-') $xau.=$str[$i]; else if ($xau!=''){$n++;$mang[$n]=$xau;$xau='';}$i++; }return $mang;}
function timepro($time){
	if ($time==0) $thoigian=''; else
	$thoigian = date("d/m/Y [H:i]", $time);
	return $thoigian;
}
function postok($user){
   $cmd="SELECT `user_ok` FROM `user` WHERE userid=".$user;
   $info=mysql_fetch_assoc(mysql_query($cmd));
   if ($info['user_ok']==1) return true; else return false;
}
function threadupdate($thread){
   $cmd="SELECT * FROM `thread` WHERE threadid=".$thread;
   $info=mysql_fetch_array(mysql_query($cmd));
   $postlastid=$info['lastpostid'];
   $postlastuser=$info['lastposter'];
   $postlasttime=$info['lastpost'];
   $postlastuserid=$info['lastposterid'];
   $cmd="UPDATE `thread` SET postlastuserid=$postlastuserid,postlastid=$postlastid,postlasttime=$postlasttime,postlastuser='$postlastuser' WHERE threadid=".$thread;
   
   mysql_query($cmd);
}
function addpost(){
   $cmd="SELECT `postid` FROM `post` ORDER BY `postid` DESC LIMIT 0,1";
   $info=mysql_fetch_assoc(mysql_query($cmd));
   $id=$info['postid']+1;
   $cmd="INSERT INTO `spam` (spam_post) VALUES ($id)";
   mysql_query($cmd);
}
function decode($word)
{
$mang=array();
$word.=' ';$str=str_split($word);$i=0;$xau='';$n=0;while ($i<=strlen($word)){if ($str[$i]!='-') $xau.=$str[$i]; else if ($xau!=''){$n++;$mang[$n]=$xau;$xau='';}$i++; }
$cmd="SELECT * FROM `select`";
$excute=mysql_query($cmd);
$i=0;
$result='';
while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	if (in_array($info['select_id'],$mang))	$result.=$info['select_art'].' | ';
return substr($result,0,strlen($result)-2);
}

function decode2($word,$m) 
{
$mang=array();
$word.=' ';$str=str_split($word);$i=0;$xau='';$n=0;while ($i<=strlen($word)){if ($str[$i]!='-') $xau.=$str[$i]; else if ($xau!=''){$n++;$mang[$n]=$xau;$xau='';}$i++; }
$cmd="SELECT * FROM `select`";
$excute=mysql_query($cmd);
$i=0;$ok=0;
$result='';
$dem1=0;
while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
{
	if (in_array($info['select_id'],$mang))	
	{
		if ($dem1>=$m){$ok=1; break;}
		$result.=$info['select_art'].' | ';
		$dem1++;		
	}
}
return substr($result,0,strlen($result)-2).(($ok==1)?'...':'');
}

function decode_cat($id)
{

$sql="SELECT * FROM cat WHERE cat_id=".$id;
$info=mysql_fetch_assoc(mysql_query($sql));
return " ".$info['cat_name']." ";
}

function enable($id){
sql();
$cmd='SELECT `module_status` FROM `module` WHERE module_id='.$id;$excute=mysql_query($cmd);$info=mysql_fetch_assoc($excute);if($info['module_status']==1) return true; else return false;
}
function menu($name){echo'<div class="article-tools clearfix"><div class="article-meta">'.$name.'</div></div>';}
function menuadv($name){echo'<h3><span>'.$name.'</span></h3>';}
function menuopen($name){echo'<div class="module module_menu"><h3><span>'.$name.'</span></h3><div class="jamod-content"><ul class="menu">';}
function menuclose(){echo'</ul></div></div>';}
function space($n){for($i=1;$i<=$n;$i++) echo '<div class="space"></div>';}
function menuget($type,$menu,$name){$link='?'.$type.'='.$menu;$id=$_GET[$type];echo'<li'; if ($id==$menu) echo ' class="mark">'; else echo '>';echo '<a href="'.$link.'"><span>'.$name.'</span></a></li>';}
function menulink($name){$link='?key='.$name; $id=$_GET['key'];echo'<li>'; echo'<a href="'.$link.'"><span>'.$name.'</span></a></li>';}
function tabscript(){echo'<script>(function($){$.organicTabs=function(el, options){var base = this;base.$el=$(el);base.$nav = base.$el.find(".nav");base.init = function(){base.options = $.extend({},$.organicTabs.defaultOptions, options);$(".hide").css({"position": "relative","top":0,"left":0,"display":"none"});base.$nav.delegate("li > a", "click",function(){var curList=base.$el.find("a.current").attr("href").substring(1),$newList=$(this),listID=$newList.attr("href").substring(1),$allListWrap=base.$el.find(".list-wrap"),curListHeight=$allListWrap.height();$allListWrap.height(curListHeight);if((listID != curList) &&(base.$el.find(":animated").length==0)){base.$el.find("#"+curList).fadeOut(base.options.speed, function(){base.$el.find("#"+listID).fadeIn(base.options.speed);var newHeight = base.$el.find("#"+listID).height();$allListWrap.animate({height: newHeight});base.$el.find(".nav li a").removeClass("current");$newList.addClass("current");});}return false;});};base.init();};$.organicTabs.defaultOptions={"speed":300};$.fn.organicTabs=function(options){return this.each(function(){(new $.organicTabs(this,options));});};})(jQuery);$(function(){$("#tab1").organicTabs();});$(function(){$("#tab2").organicTabs();});jQuery(document).ready(function($){var triggers = $("#LoginWithAjax_Links_Register").overlay({mask:{color:#ebecff,loadSpeed:200,opacity:0.9},closeOnClick: true});});</script>';}
function SWF(){echo'<script type="text/javascript">if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;</script>';
}
function format($word){$word.=' ';$result='';$str=str_split($word);$i=0;$xau='';$n=0;while ($i<=strlen($word)){if ($str[$i]!=' ')$xau.=$str[$i]; else if ($xau!=''){$n++;$mang[$n]=$xau;$xau='';}$i++;}for ($i=1; $i<=$n-1;$i++) $result.=$mang[$i].'-';
$result.=$mang[$n]; return $result;}
function convert($word){$VI=array('à','á','ạ','ả','ã','â','ầ','ấ','ậ','ẩ','ẫ','ă','ằ','ắ','ặ','ẳ','ẵ','è','é','ẹ','ẻ','ẽ','ê','ề','ế','ệ','ể','ễ','ì','í','ị','ỉ','ĩ','ò','ó','ọ','ỏ','õ','ô','ồ','ố','ộ','ổ','ỗ','ơ','ờ','ớ','ợ','ở','ỡ','ù','ú','ụ','ủ','ũ','ư','ừ','ứ','ự','ử','ữ','ỳ','ý','ỵ','ỷ','ỹ','đ','À','Á','Ạ','Ả','Ã','Â','Ầ','Ấ','Ậ','Ẩ','Ẫ','Ă','Ằ','Ắ','Ặ','Ẳ','Ẵ','È','É','Ẹ','Ẻ','Ẽ','Ê','Ề','Ế','Ệ','Ể','Ễ','Ì','Í','Ị','Ỉ','Ĩ','Ò','Ó','Ọ','Ỏ','Õ','Ô','Ồ','Ố','Ộ','Ổ','Ỗ','Ơ','Ờ','Ớ','Ợ','Ở','Ỡ','Ù','Ú','Ụ','Ủ','Ũ','Ư','Ừ','Ứ','Ự','Ử','Ữ','Ỳ','Ý','Ỵ','Ỷ','Ỹ','Đ');$EN=array('a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','e','e','e','e','e','e','e','e','e','e','e','i','i','i','i','i','o','o','o','o','o','o','o','o','o','o','o','o','o','o','o','o','o','u','u','u','u','u','u','u','u','u','u','u','y','y','y','y','y','d','A','A','A','A','A','A','A','A','A','A','A','A','A','A','A','A','A','E','E','E','E','E','E','E','E','E','E','E','I','I','I','I','I','O','O','O','O','O','O','O','O','O','O','O','O','O','O','O','O','O','U','U','U','U','U','U','U','U','U','U','U','Y','Y','Y','Y','Y','D');return str_replace($VI,$EN,$word);}
function tag($word){$word.=' ';$result='';$str=str_split($word);$i=0;$xau='';$n=0;while ($i<=strlen($word)){if ($str[$i]!=' ')$xau.=$str[$i]; else if ($xau!=''){$n++;$mang[$n]=$xau;$xau='';}$i++;}for ($i=1;$i<=$n;$i++)$x[$i]=$i;for ($k=1;$k<=$n;$k++){for ($i=1;$i<=$k;$i++){for ($j=$i;$j<=$n-$k+$i;$j++) $result.=$mang[$x[$j]].' ';$result.=',';}}return $result;}
function readmore($word,$m){$word.=' ';$result='';$str=str_split($word);$i=0;$xau='';$n=0;while ($i<=strlen($word)){if ($str[$i]!=' ')$xau.=$str[$i]; else if ($xau!=''){$n++;$mang[$n]=$xau;$xau='';}$i++;}if ($n<=$m) return $word; else{for ($i=1;$i<=$m-1;$i++) $result.=$mang[$i].' ';$result.=$mang[$i].' ...';return $result;}}
function readmore_no($word,$m){$word.=' ';$result='';$str=str_split($word);$i=0;$xau='';$n=0;while ($i<=strlen($word)){if ($str[$i]!=' ')$xau.=$str[$i]; else if ($xau!=''){$n++;$mang[$n]=$xau;$xau='';}$i++;}if ($n<=$m) return $word; else{for ($i=1;$i<=$m-1;$i++) $result.=$mang[$i].' ';$result.=$mang[$i];return $result;}}
function box($x,$y){} 
function sql(){mysql_connect('localhost','cailuongso','0903010130') or die('Cant connect ! ');mysql_select_db('cailuong_beta');mysql_query('SET NAMES "utf8"');} 
function sql2(){mysql_connect('localhost','cailuongso','0903010130');mysql_select_db('cailuong_diendan'); mysql_query('SET NAMES "latin1"');}
sql();

?>